﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;

namespace WpfWordsLearner
{
	/// <summary>
	/// Interaktionslogik für "App.xaml"
	/// </summary>
	public partial class App : Application
	{
		public App()
		{
			this.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
		}

		protected override void OnStartup(StartupEventArgs e)
		{
			base.OnStartup(e);

			string location = System.Reflection.Assembly.GetExecutingAssembly().Location;
			if (location.Length > 1)
			{
				WordsManager.Instance.SetPreference(System.IO.Path.Combine(System.IO.Path.GetDirectoryName(location), @"Content\Words.xml"));
			}

			WpfWordsLearner.Views.Window1 window = new Views.Window1();
			ViewModels.Windows1ViewModel model = new ViewModels.Windows1ViewModel();
			window.DataContext = model;
			App.Current.MainWindow = window;
			window.Show();
		}

		protected override void OnExit(ExitEventArgs e)
		{
			base.OnExit(e);
			WordsManager.Instance.SaveChanges();
		}
	}

}
